package com.example.riskmanage.controller;

import com.alibaba.fastjson.serializer.SerializerFeature;
import com.example.riskmanage.bean.MainMenu;
import com.example.riskmanage.service.MenuManager;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import com.alibaba.fastjson.JSON;
import java.util.HashMap;
import java.util.List;

@RestController
public class MenuController {

    @Autowired
    MenuManager menuManager;


    @RequestMapping("/menus")
    public String getAllMenus(){

        HashMap<String, Object> data = new HashMap<>();

        List<MainMenu> menus=menuManager.MenuService();
        if (menus != null) {
            data.put("menus", menus);
            data.put("flag", 200);
        } else {
            data.put("flag", 404);
        }

        return JSON.toJSONString(data, SerializerFeature.DisableCircularReferenceDetect);
    }


}
